<template>
  <div class="container" >
   
        <van-image
      width="100"
      height="100"
      src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fstatic.bjx.com.cn%2FEnterpriseNew%2FCompanyLogo%2F37936%2F2020030417595963_852010.jpeg&refer=http%3A%2F%2Fstatic.bjx.com.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614908327&t=b990cd7cfd350d33df1c1d3033fdc9aa"
    />
    <h3>九五电力</h3>

    <van-form @submit="onSubmit">
      <van-field
        v-model="approver_num"
        name="approver_num"
        label="用户名"
         left-icon="user-o"
        placeholder="用户名"
        :rules="[{ required: true, message: '请填写用户名' }]"
      />
      <van-field
        v-model="approver_pwd"
        type="password"
        name="approver_pwd"
        label="密码"
         left-icon="closed-eye"
        placeholder="密码"
        :rules="[{ required: true, message: '请填写密码' }]"
      />
      <div style="margin: 16px;">
        <van-button round block type="info" native-type="submit">
          登录
        </van-button>
      </div>
    </van-form>
  </div>
</template>

<script>
import { Toast } from 'vant';
import axios from 'axios'
import {setCookie} from 'Utils/cookie'
import {mapState,mapActions} from 'vuex'
export default {
  data() {
    return {
      approver_num: "",
      approver_pwd: "",
      code:this.$route.query,
      openid:this.$route.query.openid,
    };
  },
  computed: {
    // ...mapState('userStore',{
    //   loginData: state => state.loginData
    // })
    
  },
  methods: {
    onSubmit(values) {
      // this.login(values)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
      this.code = this.loginData
      console.log('onsubmit')
      axios({
      url:'/hrkc/Approver/dolog',
      method:'POST',
      params:{
         approver_num: this.approver_num,
          approver_pwd: this.approver_pwd,
          // openid:this.openid                                     
          openid: 'oArWEwTjJ3LGsfdPKO6JJnv7BzdE'
        },
    }).then(res=>{
    console.log('code',res)
    if(res.data.code == 0){
      setCookie('user_flag',res.data.user_flag)
      setCookie('org_name',res.data.org_name,7)
    setCookie('openid',res.data.openid,7)
    setCookie('approver_id',res.data.approver_id,7)
    setCookie('approver_name',res.data.approver_name,7)
     setCookie('approver_b_id',res.data.approver_b_id,7)
    setCookie('approver_b_name',res.data.approver_b_name,7)
    setCookie('grade_id',res.data.grade_tree,7)
   setCookie('class',res.data.flag,7)
    this.$router.push({
      path:'/select',
      query:{
        flag:res.data.flag
        }
    })
    } else {
      Toast.fail(res.data.msg)
    }
    
    }).catch()
    },
  },
  mounted(){
    // console.log(this.$route.query.openid)
    
  }
 

};
</script>

<style lang="scss" scoped>
.van-image{
  margin: 20px 0px 0px 140px ;
  box-shadow: 2px 4px 6px #ccc ;
}
h3{
   margin:10px 0px 50px 150px ;
  // padding: 0px auto;
}

</style>

